package csci5828.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import csci5828.tasks.RequestId;
import csci5828.tasks.TaskManager;
import csci5828.tasks.TaskSet;
import csci5828.tasks.test.WaitTaskSet;

public class WaitTaskServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		//PrintStream out = new PrintStream(resp.getOutputStream());
		//out.println("<html><head><title>Congratulations!</title></head><body><h1>Hello, and welcome.</h1></body></html>");
		
		TaskSet<String> taskSet = new WaitTaskSet(new int[]{200,400,600,800});
		TaskManager<String> taskManager = TaskManagerUtil.getInstance().taskManager;
		RequestId requestId = taskManager.submit(taskSet);
		
		req.setAttribute("requestId", requestId);
		
		RequestDispatcher rd = getServletContext().getRequestDispatcher("/pages/waittaskresults.jsp");
		rd.forward(req, resp);
	}

	private static final long serialVersionUID = 1L;
	
	

}
